package com.stadium.web.domain;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

/**
 * 预定对象 reserve
 * 
 * @author ruoyi
 * @date 2020-03-15
 */
@ApiModel("预定实体类")
@Table(name="reserve")
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Reserve implements Serializable
{
    private static final long serialVersionUID = 1L;

    @Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
/** ID */
@Column(name = "ID")
@ApiModelProperty("ID")
private Long id;

    /** 预定场馆 */
    @Column(name = "VENUE_ID")
    @ApiModelProperty("预定场馆")
    private Long venueId;

    /** 预定人 */
    @OrderBy("desc")
    @JsonFormat(pattern="yyyy-MM-dd  HH:mm")
    @Column(name = "USER_ID")
    @ApiModelProperty("预定人")
    private Long userId;

    /** 预定时间 */
    @OrderBy("desc")
    @JsonFormat(pattern="yyyy-MM-dd  HH:mm")
    @Column(name = "RESERVE_TIME")
    @CreatedDate
    @ApiModelProperty("预定时间")
    private Date reserveTime;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "VENUE_ID",insertable = false,updatable = false)
    @JsonIgnoreProperties(value={"reserves"})
    private Venue venue;

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setVenueId(Long venueId)
    {
        this.venueId = venueId;
    }

    public Long getVenueId()
    {
        return venueId;
    }

    public void setReserveTime(Date reserveTime) 
    {
        this.reserveTime = reserveTime;
    }

    public Date getReserveTime() 
    {
        return reserveTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("venueId", getVenueId())
            .append("userId", getUserId())
            .append("reserveTime", getReserveTime())
            .toString();
    }
}
